package com.matt.docpro.controller;

import com.matt.docpro.config.Utils;
import com.matt.docpro.model.*;
import com.matt.docpro.service.*;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * DoctorController
 * Created by on 2024/02/07.
 */
@Controller
public class ClinicController {

    @Autowired
    AppointmentService appointmentService;
    @Autowired
    ReviewService reviewService;
    @Autowired
    DoctorService doctorService;
    @Autowired
    PatientService patientService;
    @Autowired
    ClinicService clinicService;
    @Autowired
    LoginInfoService loginInfoService;

    @RequestMapping("/clinic-1")
    public String clinicList(Model model, HttpServletRequest request) throws Exception {
        String token = Utils.getToken(request);
        User user = loginInfoService.getUserByToken(token);
        List<Clinic> clinics = clinicService.getAll();
        model.addAttribute("clinics", clinics);
        model.addAttribute("user", user);
        return "clinic-1";
    }

    @RequestMapping("/clinic-details")
    public String clinicDetail(Model model, String clinicId, HttpServletRequest request) throws Exception {
        String token = Utils.getToken(request);
        User user = loginInfoService.getUserByToken(token);
        Clinic clinic = clinicService.getById(clinicId);
        model.addAttribute("clinic", clinic);
        model.addAttribute("user", user);
        return "clinic-details";
    }
}
